import { getSysUser, getMenu } from "@/api/user";
const state = {
  user: [],
  userMenu: [],
};

const mutations = {
  SET_USER: (state, data) => {
    state.user = data;
  },
  SET_USER_MENU: (state, data) => {
    state.userMenu = data;
  },
};

const actions = {
  // 查询
  getSysUser({ commit }, params) {
    return new Promise((resolve, reject) => {
      getSysUser(params)
        .then((res) => {
          resolve(res);
        })
        .catch((error) => {
          reject(error);
        });
    });
  },
  getMenu({ commit }, params) {
    return new Promise((resolve, reject) => {
      getMenu(params)
        .then((res) => {
          let menu = res.data;
          commit("SET_USER_MENU", menu);
          resolve(res);
        })
        .catch((error) => {
          reject(error);
        });
    });
  },
};

/**
 * 系统人员
 */
export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
